﻿using Microsoft.AspNet.SignalR;
using System.Threading.Tasks;
using ZSoft.PushServices.Net.DTO;
using ZSoft.PushServices.Net.Transport.ConnectionEvents;

namespace ZSoft.PushServices.Net.Transport.Hubs
{
    public class HubBase: Hub
    {
        public void Identified(ClientInfoDTO info)
        {
            ConnectionEventManager.ExecuteHandlers(ConnectionEventTypes.DeviceIdentified, Context, info);
        }

        public override Task OnConnected()
        {
            ConnectionEventManager.ExecuteHandlers(ConnectionEventTypes.OnConnected, Context, null);
            return base.OnConnected();
        }

        public override Task OnReconnected()
        {
            ConnectionEventManager.ExecuteHandlers(ConnectionEventTypes.OnReconnected, Context, null);
            return base.OnReconnected();
        }

        public override Task OnDisconnected(bool stopCalled)
        {
            ConnectionEventManager.ExecuteHandlers(ConnectionEventTypes.OnDisconnected, Context, null);
            return base.OnDisconnected(stopCalled);
        }
    }
}
